package com.summer.web.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by thinkpad on 2018/7/14.
 */

@Configuration
public class RegistrationConfig {

    @Bean
    public FilterRegistrationBean demoFilter1(){

        FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
        filterRegistration.setFilter(new DemoFilter1());
        filterRegistration.setOrder(4);
        List<String> urlPatterns = new ArrayList<>();
        urlPatterns.add("/*");
        filterRegistration.setUrlPatterns(urlPatterns);

        return filterRegistration;
    }


    @Bean
    public FilterRegistrationBean demoFilter2(){

        FilterRegistrationBean filterRegistration = new FilterRegistrationBean();
        filterRegistration.setFilter(new DemoFilter2());
        filterRegistration.setOrder(3);
        List<String> urlPatterns = new ArrayList<>();
        urlPatterns.add("/*");
        filterRegistration.setUrlPatterns(urlPatterns);

        return filterRegistration;
    }



}
